﻿@model  Model.PageRole
@{
    ViewBag.Title = "数据质量日志管理";
    Layout = "~/Views/Shared/_Main.cshtml";
}
<script src="/Res/easyui/locale/easyui-lang-zh_CN.js" type="text/javascript"></script>
<style>
    #ClearLogDialog
    {
        width: 500px;
        height: 150px;
        display: none;
        line-height: 20px;
        position: absolute;
        top: 62px;
        left: 220px;
        z-index: 1002;
        word-wrap: break-word;
        word-break: normal;
        background-color: #ffffff;
    }
</style>
<script type="text/javascript">
    function ButtonSearch(p) {
        opts.para["DQName"] = $.trim($("#sel_DQName").val());
        opts.para["DQMessage"] = $.trim($("#sel_DQMessage").val());
        opts.para["TimeFrom"] = $.trim($(".sel_TimeFrom").datebox('getValue'));
        opts.para["TimeTo"] = $.trim($(".sel_TimeTo").datebox('getValue'));
        thisPageNum = 1;
        $("#DataGrid").dg(opts);
    }
    function SelectDate(id) {
        $('#' + id).datebox('enable');
    }
    function ClearLogDialog() {
        $('#ClearLogDialog').show();
        $('#DIVMask').show();
    }
    function ClearLog(id) {
        var a = $(".delDate").datebox('getValue');
        if (a == "") {
            alert("请选择删除日期。");
            return;
        }
        var arr = a.split("-");
        var starttime = new Date(arr[0], arr[1], parseInt(arr[2]) + 1);
        var starttimes = starttime.getTime();

        var b = new Date();
        var btimes = new Date(b.getFullYear(), b.getMonth() + 1, b.getDate());
        if (starttimes > btimes.getTime()) {
            alert("删除日期应该小于当前日期。");
            return;
        }
        if (confirm("确定要清空DQ日志吗？")) {
            $.post("/SysLog/ClearDQLog/?dbName=" + encodeURI($.getUrlParam("dbName")) + "&date=" + a, function (res) {
                if (res == "1") {
                    alert("操作成功！");
                    $('#ClearLogDialog').hide();
                    $('#DIVMask').hide();
                    ButtonSearch(1)
                }
                else if (res == "0")
                    alert("删除失败！");
                else
                    alert("删除失败！" + res);
            });
        }
    }
    function View(id) {
        showModalMany('Contact', "/SysLog/ReadDQLog?id=" + id + "&dbName=" + encodeURI($.getUrlParam("dbName")), '520', '260', "off");
    }
    var opts = {
        rows: 15,
        height: 450,
        para: {},
        idField: "Guid",
        url: "/SysLog/SysDQLogList?dbName=" + encodeURI($.getUrlParam("dbName")),
        columns: [
            { field: 'DQName', title: '数据质量名称', width: 20 },
            { field: 'DQTypeID', title: '数据质量类型', width: 20 },
            { field: 'DQMessage', title: '日志信息', width: 40 },
            { field: 'DQTime', title: '操作时间', width: 15, align: 'center' },
            { field: 'Guid', title: '操作', width: 8, align: 'center', formatter: function (value, rowData, rowIndex) {
                return "<a onclick='View(\"" + value + "\");' class='grid_a'>查看</a>";
            }
            }
            ]
    };
    $(function () {
        $("#DataGrid").dg(opts);
    });
</script>
<div style="margin: 5px;">
    <table class="listTitle">
        <tr>
            <td width="15">
                <img src="/images/search.png" />
            </td>
            <td width="300">
                数据质量日志搜索
            </td>
            <td align="right">
            </td>
        </tr>
    </table>
    <table class="searchArea" width="100%">
        <tr>
            <td>
                数据质量名称：
                <input id="sel_DQName" type="text" style="width: 150px;" />
                日志关键字：
                <input id="sel_DQMessage" type="text" style="width: 150px;" />
                操作时间：从
                <input type="text" style="width: 150px;" class="easyui-datetimebox sel_TimeFrom"
                    onclick="SelectDate('sel_TimeFrom')" />
                <input id="sel_TimeFrom" type="hidden" />
                到
                <input type="text" style="width: 150px;" class="easyui-datetimebox sel_TimeTo" onclick="SelectDate('sel_TimeTo')" />
                <input id="sel_TimeTo" type="hidden" />
                <input type="button" class="button" value=" 搜索 " onclick="ButtonSearch(1)" />
            </td>
        </tr>
    </table>
    <table class="listTitle">
        <tr>
            <td width="15">
                <img src="/images/edit.png" />
            </td>
            <td width="300">
                数据质量日志列表
            </td>
            <td align="right">
                @if (Model.role == 2)
                {
                    <input type="button" class="button" value="清除日志" onclick="ClearLogDialog();" />
                }
            </td>
        </tr>
    </table>
    <table id="DataGrid" class="pagTable" cellpadding="0" cellspacing="0">
    </table>
    <div>
        <div id="Pagination" class="pagination">
        </div>
        <div id="loading" class="loading">
            <img src="/Images/tree_loading.gif" />
        </div>
    </div>
    <div id="msg">
    </div>
</div>
<div id="ClearLogDialog">
    <table class="listTitle">
        <tbody>
            <tr>
                <td width="15">
                    <img src="/images/search.png">
                </td>
                <td width="260">
                    清除数据质量日志
                </td>
                <td align="right">
                    <input type="button" class="button" value=" 清除 " onclick="ClearLog()" />
                    <input type="button" class="button" value="关闭" onclick="$('#ClearLogDialog').hide();$('#DIVMask').hide();" />
                </td>
            </tr>
        </tbody>
    </table>
    <div style="width: 488px; height: 100px; padding: 5px; border: #ccc 1px solid;">
        删除日期：<input type="text" style="width: 110px;" class="easyui-datebox delDate" onclick="SelectDate('sel_ClearlogTime')" />
        <input id="sel_ClearlogTime" type="hidden" />之前的记录.
    </div>
</div>
<div id="DIVMask">
</div>
